#ifndef QMISSIONMANAGER_H
#define QMISSIONMANAGER_H

#include "communicate_global.h"

#include <QObject>
#include <QMap>
#include <QStringList>

class QMission;

class COMMUNICATE_EXPORT QMissionManager : public QObject
{
    Q_OBJECT
public:
    explicit QMissionManager(QObject *parent = 0);
    ~QMissionManager();

    void    add_mission(QMission* ms);
    void    remove_mission(QMission* ms);
    void    remove_mission(const QString &id);

    void    set_search();

    QMission* get_mission(const QString &id);


    void    add_mission_group(const QList<QMission*> list,const QString &name);
    QString group_mission_name();
    void    clear();

    QMission*   get_need_to_do();

    void    clear_delete(const QString &id);

    void    reset();

    void    pause(const QStringList &list=QStringList());

    void    set_connect_mission(QMission* ms);

    void    mission_done(QMission* ms,int code);
signals:
    void    offline();
    void    online();

    void    mission_group_end(bool success);
    void    mission_group_progress(int count);
    void    mission_group_start(int count);

    void    mission_failed(QMission* ms,int code);
    void    mission_success(QMission* ms);

    void    machine_version(int version);
protected:
    QList<QMission*>        m_missions;
    QList<QMission*>        m_pause_list;
    QList<QMission*>        m_delete_list;
    QMission*               m_connect_test_mission;
    QList<QMission*>        m_mission_group;
    QString                 m_mission_group_name;
    QMap<QString,QMission*> m_id_to_mission;
    bool                    m_online;
    bool                    m_is_search;
};

#endif // QMISSIONMANAGER_H
